<?php
namespace Application\Repository;
use Doctrine\ORM\EntityRepository;

class FriendFacebookRepository extends AbstractRepository
{
    protected $entity="Application\\Entity\\FriendFacebook";
    
    public function getByUserFacebook($userId,$number = 5000)
    {
        $dql = "SELECT c FROM $this->entity c WHERE IDENTITY(c.userFrom)=?1 OR IDENTITY(c.userTo)=?2";

        return $this->getEntityManager()->createQuery($dql)
                             ->setParameter(1, $userId)
                             ->setParameter(2, $userId)
                             ->setMaxResults($number)
                             ->getResult();
    }
    
    public function getByUserFacebookTo($userToId,$number = 5000)
    {
    	$dql = "SELECT c FROM $this->entity c WHERE IDENTITY(c.userTo)=?1";
    
    	return $this->getEntityManager()->createQuery($dql)
    	->setParameter(1, $userToId)
    	->setMaxResults($number)
    	->getResult();
    }
    
    public function getByUserFacebookFrom($userFormId,$number = 5000)
    {
        $dql = "SELECT c FROM $this->entity c WHERE IDENTITY(c.userFrom)=?1";

        return $this->getEntityManager()->createQuery($dql)
                             ->setParameter(1, $userFormId)
                             ->setMaxResults($number)
                             ->getResult();
    }
}